import GameObject from "../GameObject";
import GameConst from "../GameConst";
import Utils from "../utils";

export default class BonusBombSprite extends GameObject{
    constructor(t, n, r) {
        super();
        var i = this;
        this.progress = 0;
        this.maxScale = 0;
        var s = t == 3 ? 2.5 : 4;
        this.maxScale = 1.75 * s * GameConst.TILE_SIZE / 65;
        Laya.Tween.to(this,{
            progress: 1
        }, 1.6 * s * 1e3 * GameConst.GEM_KILL_DELAY, Laya.Ease.cubicOut,Laya.Handler.create(this,this.destroy()));
        this.sprite = Utils.createBitmap("explosion_bomb");
        this.sprite.x = n;
        this.sprite.y = r;
        this.sprite.pivotX = this.sprite.pivotY = 135 / 2;
        Utils.addChild(this.sprite, GameConst.level.bonusLayer);
        GameConst.level.objects.push(this);
    }
    update(e) {
        this.sprite.scaleX = this.sprite.scaleY = Utils.lerp(.1, this.maxScale, this.progress);
        this.sprite.alpha = this.progress < .6 ? Utils.lerp(.3, 1, this.progress / .6) : Utils.lerp(1, 0, (this.progress - .6) / .4);
    }
}